home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 March / PCWorld_2001-03_cd.bin / Software / TemaCD / classbuild / ClassBuilder 2.2 PR405 Setup.exe / {app} / Include / CB_CriticalSingleOwned.h < prev    next >
C/C++ Source or Header  |  2000-04-06  |  5KB  |  134 lines

  1. #ifndef CB_CRITICAL_SINGLE_OWNED_H
  2. #define CB_CRITICAL_SINGLE_OWNED_H
  3.  
  4. #include "CB_CriticalSingle.h"
  5. #include "CB_SingleOwned.h"
  6.  
  7. // defines for include files
  8. #define RELATION_TEMPLATE_CRITICAL_SINGLE_OWNED_ACTIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  9. public:\
  10.     ClassTo* _ref##NameTo;\
  11. \
  12.     static CriticalSection& CriticalSection##NameTo()\
  13.     {\
  14.         static CriticalSection criticalSection##NameTo;\
  15.         return criticalSection##NameTo;\
  16.     }\
  17. \
  18. protected:\
  19.     void Add##NameTo(ClassTo* item)\
  20.     {\
  21.         CriticalSectionLock lock(ClassFrom::CriticalSection##NameTo());\
  22.         METHOD_SINGLE_ADD(ClassFrom, NameFrom, ClassTo, NameTo) \
  23.     }\
  24.     \
  25.     void Remove##NameTo(ClassTo* item)\
  26.     {\
  27.         CriticalSectionLock lock(ClassFrom::CriticalSection##NameTo());\
  28.         METHOD_SINGLE_REMOVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  29.     }\
  30.     \
  31.     void Replace##NameTo(ClassTo* item, ClassTo* newItem)\
  32.     {\
  33.         CriticalSectionLock lock(ClassFrom::CriticalSection##NameTo());\
  34.         METHOD_SINGLE_REPLACE(ClassFrom, NameFrom, ClassTo, NameTo) \
  35.     }\
  36.     \
  37. public:\
  38.     void Move##NameTo(ClassTo* item)\
  39.     {\
  40.         CriticalSectionLock lock(ClassFrom::CriticalSection##NameTo());\
  41.         METHOD_SINGLE_MOVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  42.     }\
  43.     \
  44.     ClassTo* Get##NameTo() const {return _ref##NameTo;};
  45.  
  46. #define RELATION_CRITICAL_SINGLE_OWNED_ACTIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  47. public:\
  48.     ClassTo* _ref##NameTo;\
  49. \
  50.     static CriticalSection _criticalSection##NameTo;\
  51.     static CriticalSection& CriticalSection##NameTo() { return _criticalSection##NameTo; }\
  52. \
  53. protected:\
  54.     void Add##NameTo(ClassTo* item);\
  55.     void Remove##NameTo(ClassTo* item);\
  56.     void Move##NameTo(ClassTo* item);\
  57.     void Replace##NameTo(ClassTo* item, ClassTo* newItem);\
  58. \
  59. public:\
  60.     ClassTo* Get##NameTo() const {return _ref##NameTo;};
  61.  
  62. #define RELATION_CRITICAL_SINGLE_OWNED_PASSIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  63.     RELATION_CRITICAL_SINGLE_PASSIVE(ClassFrom, NameFrom, ClassTo, NameTo)
  64.  
  65. // defines implementation
  66. #define INIT_CRITICAL_SINGLE_OWNED_ACTIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  67.    INIT_SINGLE_OWNED_ACTIVE(ClassFrom, NameFrom, ClassTo, NameTo)
  68.  
  69. #define EXIT_CRITICAL_SINGLE_OWNED_ACTIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  70. {\
  71.     CriticalSectionLock lock(ClassFrom::CriticalSection##NameTo());\
  72.     EXIT_SINGLE_OWNED_ACTIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  73. }
  74.  
  75. #define REPLACE_CRITICAL_SINGLE_OWNED_ACTIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  76. {\
  77.     CriticalSectionLock lock(ClassFrom::CriticalSection##NameTo());\
  78.     REPLACE_SINGLE_OWNED_ACTIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  79. }
  80.  
  81. #define INIT_CRITICAL_SINGLE_OWNED_PASSIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  82. {\
  83.     CriticalSectionLock lock(ClassFrom::CriticalSection##NameTo());\
  84.     INIT_SINGLE_OWNED_PASSIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  85. }
  86.  
  87. #define EXIT_CRITICAL_SINGLE_OWNED_PASSIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  88. {\
  89.     CriticalSectionLock lock(ClassFrom::CriticalSection##NameTo());\
  90.     EXIT_SINGLE_OWNED_PASSIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  91. }
  92.  
  93. #define REPLACE_CRITICAL_SINGLE_OWNED_PASSIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  94. {\
  95.     CriticalSectionLock lock(ClassFrom::CriticalSection##NameTo());\
  96.     REPLACE_SINGLE_OWNED_PASSIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  97. }
  98.  
  99. #define REMOVE_CRITICAL_SINGLE_OWNED_ACTIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  100. {\
  101.     CriticalSectionLock lock(ClassFrom::CriticalSection##NameTo());\
  102.     REMOVE_SINGLE_OWNED_ACTIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  103. }
  104.  
  105. #define SAVE_CRITICAL_SINGLE_OWNED_PASSIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  106. {\
  107.     CriticalSectionLock lock(ClassFrom::CriticalSection##NameTo());\
  108.     SAVE_SINGLE_OWNED_PASSIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  109. }
  110.  
  111. #define RESTORE_CRITICAL_SINGLE_OWNED_PASSIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  112. {\
  113.     CriticalSectionLock lock(ClassFrom::CriticalSection##NameTo());\
  114.     RESTORE_SINGLE_OWNED_PASSIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  115. }
  116.  
  117. #define REMOVE_CRITICAL_SINGLE_OWNED_PASSIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  118. {\
  119.     CriticalSectionLock lock(ClassFrom::CriticalSection##NameTo());\
  120.     REMOVE_SINGLE_OWNED_PASSIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  121. }
  122.  
  123. #define CLEANUP_CRITICAL_SINGLE_OWNED_PASSIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  124. {\
  125.     CriticalSectionLock lock(ClassFrom::CriticalSection##NameTo());\
  126.     CLEANUP_SINGLE_OWNED_PASSIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  127. }
  128.  
  129. #define METHODS_CRITICAL_SINGLE_OWNED_ACTIVE(ClassFrom, NameFrom, ClassTo, NameTo) \
  130.     METHODS_CRITICAL_SINGLE_ACTIVE(ClassFrom, NameFrom, ClassTo, NameTo) 
  131.  
  132. #define METHODS_CRITICAL_SINGLE_OWNED_PASSIVE(ClassFrom, NameFrom, ClassTo, NameTo)
  133.  
  134. #endif